package com.mlnx.stream.listener.iml;

import cn.hutool.core.date.DateUtil;
import com.mlnx.common.utils.MyLog;
import com.mlnx.data.entity.SugarInfo;
import com.mlnx.data.service.SugarDataService;
import com.mlnx.stream.listener.SugarListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by amanda.shan on 2019/10/27.
 */
@Component
public class SugarStoreListener implements SugarListener {

    private MyLog log = MyLog.getLog(getClass());

    @Autowired
    private SugarDataService sugarDataService;

    @Override
    public void receiveSugarInfo(SugarInfo sugarInfo) {

        sugarDataService.save(sugarInfo);
        log.info("保存血糖 病人ID：{} {} {}", sugarInfo.getPatientId(),
                sugarInfo.getResult(),
                DateUtil.formatDateTime(new Date()));
    }

}
